-- @owner:魏亚军
-- @date:2023-12-25
-- @testpoint:10.测试修改序列起始值,事务中修改

--step1:创建一个普通序列，起始值为1，无最小值，最大值为5，步长为-2，其他属性默认;expect:成功(1 row)
drop large sequence if exists seqopengauss_alter_sequence_start_case0010_1;
create large sequence seqopengauss_alter_sequence_start_case0010_1 nominvalue increment -2 start 1 maxvalue 5;

--step2:查看设置是否生效;expect:成功(1 row)
select start_value from information_schema.sequences where sequence_name='seqopengauss_alter_sequence_start_case0010_1';

--step3:修改序列起始值为-3;expect:成功(1 row)
begin
alter large sequence seqopengauss_alter_sequence_start_case0010_1 start -3;
end;
/

--step4:查看修改是否生效;expect:成功(1 row)
select start_value from information_schema.sequences where sequence_name='seqopengauss_alter_sequence_start_case0010_1';

--step5:将序列重新开始;expect:成功
alter large sequence seqopengauss_alter_sequence_start_case0010_1 restart;

--step6:验证实际起始值是否已经修改;expect:成功(1 row)
select nextval('seqopengauss_alter_sequence_start_case0010_1');

--step7:修改序列起始值为5;expect:成功
begin;
alter large sequence seqopengauss_alter_sequence_start_case0010_1 start 5;
--step8:提交事务;expect:成功
end;
/

--step9:查看修改是否生效;expect:成功(1 row)
select start_value from information_schema.sequences where sequence_name='seqopengauss_alter_sequence_start_case0010_1';

--step10:将序列重新开始;expect:成功
alter large sequence seqopengauss_alter_sequence_start_case0010_1 restart;

--step11:验证实际起始值是否已经修改;expect:成功(1 row)
select nextval('seqopengauss_alter_sequence_start_case0010_1');

--step12:清理环境:expect:成功(1 row)
drop large sequence seqopengauss_alter_sequence_start_case0010_1;